package com.nxy.dao;

import com.nxy.entity.Message;

import java.util.List;

public class MessageDao extends BaseDao<Message>{
    public int addMessage(Message m){
        String sql = "insert into message(msg,img,ved) values(?,?,?)";
        return update(sql,m.getMsg(),m.getImg(),m.getVed());
    }

    public List<Message> queryMessage(){
        String sql = "select * from message";
        return queryMore(sql,Message.class);
    }

    public int deleteMessage(String id){
        String sql = "delete from message where id = ?";
        return update(sql,id);
    }

    public Message queryMessageById(String id){
        String sql="select * from message where id=?";
        return queryOne(sql,Message.class,id);
    }

    public int updateMessage(Message m){
        String sql = "update message set msg=? where id = ?";
        return update(sql,m.getMsg(),m.getId());
    }
}
